#include <stdio.h>
#include <malloc.h>

typedef struct node{

	int data;
	struct node *next;
}Node;


Node * Linklist_creat(void)
{
	Node *head;
	head = (Node *)malloc(sizeof(struct node));
	head->data = 0;
	head->next = NULL;
	return head;
}

Node *Linklist_insert(Node *head,int value)
{
	Node *p,*q;
	p = (Node *)malloc(sizeof(struct node));
	p->data = value;
	q = head;
	while(q->next != NULL)
	{
		q = q->next;
	}
	p->next = q->next;
	q->next = p;
	return p;
}

int Linklist_delete(Node *target)
{
	Node *p;
	if(target == NULL)
	{
		return -1;
	}
	p = target->next;
	if(p == NULL)
	{
		free(target);
		target = NULL;
	}
	else
	{
		target->data = p->data;
		target->next = p->next;
		free(p);
		p = NULL;
	}
	return 0;
}
	
	
int main()
{
	int a = 10 ,b = 15;
	Node *link1,*link2,*link3;
	
	link1 = Linklist_creat();
	link2 = Linklist_insert(link1,a);
	link3 = Linklist_insert(link1,b);

	printf("%d\n",link1->data);
	printf("%d\n",link1->next->data);
	printf("%d\n",link1->next->next->data);
	
	Linklist_delete(link3);
	printf("%d\n",link1->data);
	printf("%d\n",link1->next->data);
	return 0;
}


